package com.xiaotu.code.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 针对字符串的处理工具类.
 * 
 * @author chenxiangrong
 * 
 */
public class StringUtil {
	/**
	 * 判断是否是null或者空字符串.
	 * 
	 * @param str
	 * @return
	 */
	public static boolean IsNullOrEmpty(String str) {
		return str == null || "".equals(str.trim())
				|| "null".equalsIgnoreCase(str);
	}

	/**
	 * 判断是否数字.
	 * 
	 * @param str
	 * @return
	 */
	public static boolean isNumeric(String str) {
		if (IsNullOrEmpty(str)) {
			return false;
		}
		Pattern pattern = Pattern.compile("[0-9]*");
		Matcher isNum = pattern.matcher(str);
		if (!isNum.matches()) {
			return false;
		}
		return true;
	}
}
